package com.zhixing.config;

import com.zhixing.controller.ISwagger2WordProcessor;
import com.zhixing.controller.SimpleSwagger2WordProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.thymeleaf.spring5.SpringTemplateEngine;

/**
 * swagger 2 word 自动配置类
 *
 * @author zhixing
 */
@Configuration
@AutoConfigureAfter({RestTemplateAutoConfig.class,TemplateAutoConfig.class, ThymeleafAutoConfiguration.class})
public class Swagger2WordAutoConfig {

    @Autowired
    private RestTemplate            restTemplate;

    @Autowired
    private SpringTemplateEngine    templateEngine;

    @Bean
    @ConditionalOnMissingBean(ISwagger2WordProcessor.class)
    public ISwagger2WordProcessor swagger2WordProcessor(){
        return new SimpleSwagger2WordProcessor(restTemplate,templateEngine);
    }
}
